using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using SubsidyApp.Models;

namespace SubsidyApp.Controllers
{
    public class AddressFormViewModel
    {
        public other_dist_address other_dist_address { get; private set; }
        public SelectList Dists { get; private set; }

        public AddressFormViewModel(other_dist_address address)
        {
            other_dist_address = address;
            Dists = new SelectList(BasesDescription.db.other_dists.AsEnumerable(), "id", "dist_title", other_dist_address.dist_id);
        }
    }

    public class LocationController : Controller
    {
        private LocationsRepository locationsRepository = new LocationsRepository();

        public ActionResult Index()
        {
            ViewData["LocationList"] = locationsRepository.GetAllDists();
            
            return View();
        }

        public ActionResult Details(int id)
        {
            ViewData["AddrList"] = locationsRepository.GetDistAddress(id);
            ViewData["Dist"] = locationsRepository.GetDistTitle(id);
            return View();
        }

        public ActionResult Address(int id)
        {
            other_dist_address distAddress = locationsRepository.GetAddress(id);
            ViewData.Model = distAddress;
            int dist_id = distAddress.dist_id;
            ViewData["AddrList"] = locationsRepository.GetDistAddress(dist_id);

            return View();
        }
    }
}
